/*
 * Copyright (c) 2018-2999 北京小象智慧信息科技有限公司 All rights reserved.
 *
 * https://www.xiaoxiangai.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */

package com.yami.shop.service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yami.shop.bean.app.dto.OrderCountData;
import com.yami.shop.bean.app.dto.OrderStaticsDto;
import com.yami.shop.bean.app.dto.ShopCartOrderMergerDto;
import com.yami.shop.bean.dto.ShopDetailSalesDto;
import com.yami.shop.bean.model.Order;
import com.yami.shop.bean.model.OrderRefund;
import com.yami.shop.bean.model.Product;
import com.yami.shop.bean.model.ShopDetail;
import com.yami.shop.bean.param.OrderParam;

import cn.hutool.core.date.DateTime;
import org.aspectj.weaver.ast.Or;
import com.yami.shop.bean.pay.RefundGoodsDto;

/**
 * @author lgh on 2018/09/15.
 */
public interface OrderService extends IService<Order> {


    Order getOrderByOrderNumber(String orderNumber);

    ShopCartOrderMergerDto putConfirmOrderCache(String userId ,ShopCartOrderMergerDto shopCartOrderMergerDto);

    ShopCartOrderMergerDto getConfirmOrderCache(String userId);

    void removeConfirmOrderCache(String userId);

    List<Order> submit(String userId, ShopCartOrderMergerDto mergerOrder,String tjr,String pickupTime,String ptglid,String purchaseType,Long prodId);

    void delivery(Order order);

    void refund(Order order);

    List<Order> listOrderAndOrderItems(Integer orderStatus, DateTime lessThanUpdateTime);

    List<Order> OrderAndOrderItems(Integer refundState,String orderNumber);

    List<Order> selectByOrderNumber(String orderNumber);

    void cancelOrders(List<Order> orders);

    void confirmOrder(List<Order> orders);

    void finishOrder(List<Order> orders);

    List<Order> listOrdersDetialByOrder(Order order, Date startTime, Date endTime);

    IPage<Order> pageOrdersDetialByOrderParam(Page<Order> page, OrderParam orderParam);

    IPage<OrderRefund> pageOrdersRefundByOrderParam(Page<OrderRefund> page, OrderParam orderParam);

    void deleteOrders(List<Order> orders);

    OrderCountData getOrderCount(String userId);

    void updatebyOrderNumber(List<Order> orders);

    void updateRefund(Order order, Integer refundState);

    String refundState(Order order);

    void dealOrderSuccess(Order order,String payNo,String bizPayNo,String orderNumber,String puserId);

    List<OrderStaticsDto> selectTodayStatics(Long shopId);
    List<OrderStaticsDto> selectYesterdayStatics(Long shopId);
    List<OrderStaticsDto> selectPendingOrder(Long shopId);
    List<OrderStaticsDto> selectTransOrder(Long shopId);
    List<OrderStaticsDto> selectCompletedOrder(Long shopId);
    List<OrderStaticsDto> selectRefund(Long shopId);
    List<OrderStaticsDto> selectAddMember(Long shopId);
    List<OrderStaticsDto> selectAllMember(Long shopId);
    List<OrderStaticsDto> selectmonthMember(Long shopId);
    List<OrderStaticsDto> selectThisMonthStatics(Long shopId);
    List<OrderStaticsDto> selectLastMonthStatics(Long shopId);
    List<OrderStaticsDto> selectThisWeekStatics(Long shopId);
    List<OrderStaticsDto> selectLastWeekStatics(Long shopId);
    List<OrderStaticsDto> selectWeekDayMoney(Long shopId);
    List<OrderStaticsDto> selectMonthDayMoney(Long shopId);

    /**
     *推送订单给美团
     */
    void pushOrderToMeiTuan(Order order) throws  Exception;

    /**
     *
     */
    List<Order> listOrderbyDvyTime(Integer orderStatus, DateTime lessThanUpdateTime);

    /**
     * 根据店铺ID获取查询的订单数据
     */
    List<Order> getOrderData(Long shopId, Page<Order> page);

    /**
     * 插入订单
     * */
    int insertOrder(Order order);

    /**
     * 根据拼团ID查询对应的订单
     */
    Order getOrderByPtglid(Long ptglid);

    /**
     * 拼团失败的订单列表
     * */
    List<Order> groupFailOrders();

    /**
     * 查询待发货订单
     */
    List<Order> getUnprocessedOrder(Long shopId);

    /**
     * 查询有订单交易的商家
     */
    IPage<Order> getShopDetailId(Page<Order> page);

    /**
     * 查询店铺销售额
     */
    Double getShopSalesVolume(Long shopId);

    /**
     * 根据年月查询有订单交易的商家
     */
    IPage<Order> getShopDetailIdByTime(ShopDetailSalesDto shopDetailSalesDto,Page<Order> page);

    /**
     * 查询用户的
     */
    Double getShopBusinessVolumeByTime(ShopDetailSalesDto shopDetailSalesDto,Long shopId);

    /**
     *  查询已过半小时未支付的订单
     */
    List<Order> listOrderNotPay(Integer orderStatus, DateTime lessThanUpdateTime);

    /**
     *  app端新增订单数据
     */
    ShopCartOrderMergerDto insertOrder(List<Product> list,Long cashier,String phoneNumber,String cid);

    Order getByOrderNumber(String orderNumber);
    /**
     * 获取该营业员下未支付的订单
     */
    List<Order> getNotPayOrder(Long cashier);

    /**
     * 支付撤销 修改订单状态
     * */
    RefundGoodsDto appOrderBackOut(String orderNumber,String merchantCode,String terminalCode,String originalOrderId,String voidPayment,String appId,String appKey,Long updateBy) throws  Exception;

    /**
     * 查询门店所有订单
     */
    List<Order> getAllOrderByshopId(Long shopId,int pageNumber,int startpageNumber);

    /**
     * 查询待配送的订单
     */
    List<Order> getDpsOrder(Long shopId,int pageNumber,int startpageNumber);

    /**
     * 查询待快递订单
     */
    List<Order> getDkdOrder(Long shopId,int pageNumber,int startpageNumber);

    /**
     * 现金支付,处理订单
     */
    String paySuccessByCash(BigDecimal actualCollection,String orderNumber);

    /**
     * 查询线上设定的时间范围内的订单
     */
    List<Order> getOrderListByEnterTime(String lessThanUpdateTime);


    List<Order> getOrderListByTodayShopAState(Long shopId,Date startTime,Date endTime);

}
